import Vue from 'vue'
import VueRouter from 'vue-router'
import SystemView from "@/views/system.vue";
import IndexView from '@/views/index.vue';
import IndexView2 from "@/views/index2.vue";
import Login from "@/views/login.vue";
import Payment1 from "@/views/payment1.vue";
import Payment2 from "@/views/payment2.vue";
import Advent from "@/views/summarize/advent.vue";
import GChannel from "@/views/summarize/gChannel.vue";
import OfflineFee from "@/views/summarize/offlineFee.vue";
import OnlineFee from "@/views/summarize/onlineFee.vue";
import PaymentSuccess from "@/views/paymentSuccess.vue";
import GreenChannel from "@/views/greenChannel.vue";
import GreenChannelOK from "@/views/greenChannelOK.vue";
import TotalFee from "@/views/summarize/totalFee.vue";

Vue.use(VueRouter)

const routes = [
    {
        path: '/',
        name: 'system',
        component: SystemView,
        meta: { menu: 'myMenu' }
    },
    {
        path: '/system',
        name: 'System',
        component: SystemView,
        meta: { menu: 'myMenu' }
    },
    {
        path: '/index',
        name: 'index',
        component: IndexView,
        meta: { menu: 'myMenu' }
    },
    {
        path: '/index2',
        name: 'index2',
        component: IndexView2,
        meta: { menu: 'myMenu2' }

    },
    {
        path: '/payment1',
        name: 'payment',
        component: Payment1,
        meta: { menu: 'myMenu2' }
    },
    {
        path: '/payment2',
        name: 'payment',
        component: Payment2,
        meta: { menu: 'myMenu2' }
    },
    {
        path: '/advent',
        name: 'advent',
        component: Advent,
        meta: { menu: 'myMenu2' }
    },
    {
        path: '/paymentSuccess',
        name: 'paymentSuccess',
        component: PaymentSuccess,
        meta: { menu: 'myMenu2' }
    },
    {
        path: '/greenChannel',
        name: 'greenChannel',
        component: GreenChannel,
        meta: { menu: 'myMenu2' }
    },
    {
        path: '/greenChannelOK',
        name: 'greenChannelOK',
        component: GreenChannelOK,
        meta: { menu: 'myMenu2' }
    },
    {
        path: '/gChannel',
        name: 'gChannel',
        component: GChannel,
        meta: { menu: 'myMenu2'}
    },
    {
        path: '/offlineFee',
        name: 'offlineFee',
        component: OfflineFee,
        meta: { menu: 'myMenu2'}
    },
    {
        path: '/onlineFee',
        name: 'onlineFee',
        component: OnlineFee,
        meta: { menu: 'myMenu2'}
    },
    {
        path: '/totalFee',
        name: 'totalFee',
        component: TotalFee,
        meta: { menu: 'myMenu2'}
    },
    {
        path: '/login',
        name: 'login',
        component: Login,
        meta: { menu: 'myMenu2' }
    },
    {
        path: '/goodsTable',
        name: 'goodsTable',
        // route level code-splitting
        // this generates a separate chunk (about.[hash].js) for this route
        // which is lazy-loaded when the route is visited.
        component: () => import(/* webpackChunkName: "about" */ '../views/goodsTable.vue'),
        meta: { menu: 'myMenu' }
    },
    {
        path: '/one',
        name: 'One',

        component: () => import( '../views/onerouter/onerouterview.vue'),
        children:[
            {
                path: '/two/:userid',
                name: 'Two',
                component: () => import('../views/onerouter/tworouter/tworouterview.vue'),
                children:[
                    {
                        path: '/third',
                        name: 'Third',

                        component: () => import('../views/onerouter/tworouter/thirdrouter/thirdrouterview.vue'),
                    }
                ]
            },
        ]
    }
]
// 防止连续点击多次路由报错
let routerPush = VueRouter.prototype.push;
let routerReplace = VueRouter.prototype.replace;
// push
VueRouter.prototype.push = function push(location) {
    return routerPush.call(this, location).catch(err => err)
}
// replace
VueRouter.prototype.replace = function push(location) {
    return routerReplace.call(this, location).catch(err => err)
}

const router = new VueRouter({
  routes
})

export default router
